package com.hutianao.gqgl.systemSetting.control;

import com.hutianao.gqgl.mybatis.entity.PtSystemSetting;
import com.hutianao.gqgl.mybatis.flexigrid.PaddingEntity;
import com.hutianao.gqgl.mybatis.flexigrid.PadingRstType;
import com.hutianao.gqgl.spring.control.BaseController;
import com.hutianao.gqgl.systemSetting.entity.SearchsystemSettingEntity;
import com.hutianao.gqgl.systemSetting.service.SystemSettingService;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.annotation.Secured;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
@RequestMapping("/config")
public class SystemSettingController extends BaseController {

    private Logger logger = LogManager.getLogger(this.getClass());

    @Autowired
    private SystemSettingService systemSettingService;


    @RequestMapping("/configpage")
    private String organPage(){
        return "systemSetting/systemSettingPage";
    }


    @RequestMapping("/querySystemInfoListByPage")
    @ResponseBody
    public PadingRstType<PtSystemSetting> querySystemInfoListByPage(SearchsystemSettingEntity search, PaddingEntity padding){
        logger.info(search);
        logger.info(padding);
        PadingRstType<PtSystemSetting> padingRstType = systemSettingService.querySystemInfoListByPage(search,padding);

        return padingRstType;
    }




    @Secured("ROLE_gqgy_data_role_add")
    @RequestMapping("/addSystemInfoInfo")
    @ResponseBody
    public String addSystemInfoInfo(PtSystemSetting ptSystemSetting){
        logger.info(ptSystemSetting);

        return jsonSuccess( systemSettingService.addSystemInfoInfo(ptSystemSetting));
    }

    @Secured("ROLE_gqgy_data_role_add")
    @RequestMapping("/updateSystemInfoInfo")
    @ResponseBody
    public String updateSystemInfoInfo(PtSystemSetting ptSystemSetting){
        logger.info(ptSystemSetting);

        return jsonSuccess( systemSettingService.updateSystemInfoInfo(ptSystemSetting));
    }

    @Secured("ROLE_gqgy_data_role_delete")
    @RequestMapping("/deleteSystemById")
    @ResponseBody
    public String deleteSystemById(@RequestParam("systemUuidArray") String systemUuidArray){
        logger.info("organUuidArray:" + systemUuidArray);
        return jsonSuccess( systemSettingService.deleteSystemById(systemUuidArray));
    }
}
